package com.rainng.coursesystem.controller.leader;

import com.rainng.coursesystem.config.themis.annotation.Leader;
import com.rainng.coursesystem.model.vo.LeaderBudgetVO;
import com.rainng.coursesystem.model.vo.response.ResultVO;
import com.rainng.coursesystem.service.leader.BudgetService;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

@Leader
@RequestMapping("/leader/budget")
@RestController
public class BudgetController {
    private final BudgetService service;

    public BudgetController(BudgetService service) {
        this.service = service;
    }

    @RequestMapping("/page/count")
    public ResultVO getPageCount(String eventName, String memberName) {
        return service.getPageCount(eventName, memberName);
    }

    @RequestMapping("/page/{index}")
    public ResultVO getPage(@PathVariable Integer index, String eventName, String memberName) {
        return service.getPage(index, eventName, memberName);
    }

    @GetMapping("/{id}")
    public ResultVO get(@PathVariable Integer id) {
        return service.get(id);
    }

    @PutMapping
    public ResultVO update(@RequestBody @Validated LeaderBudgetVO vo) {
        return service.update(vo);
    }
}
